package cn.tedu.common.exception;


import cn.tedu.common.response.StatusCode;
import cn.tedu.common.web.ServiceCodeEnum;
import lombok.Getter;

//1.自定义业务异常类
public class ServiceException extends RuntimeException{
    @Getter
    private StatusCode statusCode;
    @Getter
    private Integer code;

    public ServiceException(StatusCode statusCode) {
        this.statusCode = statusCode;
    }

    public ServiceException(Integer code, String message) {
        super(message);
        this.code = code;
    }

    public ServiceException(ServiceCodeEnum codeEnum, String message) {
        super(message);
        this.code = codeEnum.getCode();
    }

    public ServiceException(ServiceCodeEnum codeEnum) {
        super(codeEnum.getMsg());
        this.code = codeEnum.getCode();
    }
}
